home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
mus
/
play
/
SPlayLib31.lha
/
superplay-lib
/
SuperPlay
/
SuperPlay_Main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-21
|
6KB
|
213 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Andreas R. Kleinert
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include "SuperPlay_Main.h"
struct Screen *Scr = NULL;
UBYTE *PubScreenName = "Workbench";
APTR VisualInfo = NULL;
struct Window *SP_Main_Wnd = NULL;
struct Gadget *SP_Main_GList = NULL;
struct Gadget *SP_Main_Gadgets[9];
UWORD SP_Main_Left = 0;
UWORD SP_Main_Top = 11;
UWORD SP_Main_Width = 522;
UWORD SP_Main_Height = 52;
UBYTE *SP_Main_Wdt = (UBYTE *)"SuperPlay V3.1, © 1994 by Andreas R. Kleinert";
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
extern struct MinList SPOGad0List;
struct Node SPOGad0Nodes[] = {
&SPOGad0Nodes[1], ( struct Node * )&SPOGad0List.mlh_Head, 0, 0, "8svx",
( struct Node * )&SPOGad0List.mlh_Tail, &SPOGad0Nodes[0], 0, 0, "voc" };
struct MinList SPOGad0List = {
( struct MinNode * )&SPOGad0Nodes[0], ( struct MinNode * )NULL, ( struct MinNode * )&SPOGad0Nodes[1] };
UWORD SP_Main_GTypes[] = {
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
LISTVIEW_KIND
};
struct NewGadget SP_Main_NGad[] = {
99, 34, 210, 16, (UBYTE *)"Load and _Convert to :", NULL, GD_ConvertGad, PLACETEXT_IN, NULL, NULL,
3, 1, 122, 16, (UBYTE *)"Load and _Play", NULL, GD_PlayGad, PLACETEXT_IN, NULL, NULL,
3, 17, 57, 16, (UBYTE *)"_Stop", NULL, GD_StopGad, PLACETEXT_IN, NULL, NULL,
61, 17, 87, 16, (UBYTE *)"Con_tinue", NULL, GD_ContGad, PLACETEXT_IN, NULL, NULL,
149, 17, 76, 16, (UBYTE *)"_Forward", NULL, GD_ForGad, PLACETEXT_IN, NULL, NULL,
226, 17, 83, 16, (UBYTE *)"_Backward", NULL, GD_BackGad, PLACETEXT_IN, NULL, NULL,
125, 1, 184, 16, (UBYTE *)"Get File _Information", NULL, GD_InfoGad, PLACETEXT_IN, NULL, NULL,
3, 34, 95, 16, (UBYTE *)"_LED", NULL, GD_LEDGad, PLACETEXT_IN, NULL, NULL,
310, 1, 209, 56, NULL, NULL, GD_SPOGad, 0, NULL, NULL
};
ULONG SP_Main_GTags[] = {
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GTLV_Labels), (ULONG)&SPOGad0List, (GTLV_ShowSelected), NULL, (LAYOUTA_Spacing), 1, (TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
FontX = Scr->RastPort.Font->tf_XSize;
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
int OpenSP_Main_Window( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = SP_Main_Left, wtop = SP_Main_Top, ww, wh;
ComputeFont( SP_Main_Width, SP_Main_Height );
ww = ComputeX( SP_Main_Width );
wh = ComputeY( SP_Main_Height );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &SP_Main_GList )))
return( 1L );
for( lc = 0, tc = 0; lc < SP_Main__CNT; lc++ ) {
CopyMem((char * )&SP_Main_NGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
SP_Main_Gadgets[ lc ] = g = CreateGadgetA((ULONG)SP_Main_GTypes[ lc ], g, &ng, ( struct TagItem * )&SP_Main_GTags[ tc ] );
while( SP_Main_GTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( SP_Main_Wnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, BUTTONIDCMP|LISTVIEWIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH,
WA_Gadgets, SP_Main_GList,
WA_Title, SP_Main_Wdt,
WA_ScreenTitle, "SuperPlay Screen",
TAG_DONE )))
return( 4L );
GT_RefreshWindow( SP_Main_Wnd, NULL );
return( 0L );
}
void CloseSP_Main_Window( void )
{
if ( SP_Main_Wnd ) {
CloseWindow( SP_Main_Wnd );
SP_Main_Wnd = NULL;
}
if ( SP_Main_GList ) {
FreeGadgets( SP_Main_GList );
SP_Main_GList = NULL;
}
}